Changed the scope of transaction and the format of error messages