Implements some exception handling