Fixed bugs in transactions