Revamp error handling