Fixed a subtle bug in the transactions handler