Fix #4171 and a number of other transaction bugs
15 files changed