Refactored the way in which errors are handled with loading models.