Transaction related stuff (adjusting slepher's patch to current code)