fixed some race conditions in transactions