Add more error checking in model loader