Normalize uniqueness errors (could use some refactoring)
Refactor error handling.