Some transaction improvements

- The locking and commit mechanism needs review
- There may be some encapsulation problems