Refactor errors a bit