Sam raet 15 Some refactoring in preparation for more reliability in transactions