Set the transaction state to unloaded in the unloader not outside.
Predecrement instead of postdecrement.