Fix bug introduced by refactoring of error handling, minor fun renaming