Refactor error classes