Fix transaction bugs