Cleaned from boilerplate and changed raise errors with abort messages