Tidy up internals, introduce new Transaction handling API