Added exception handling, transactions