Finally done, database transactions working correctly