Better error logging and model validation.