Added logging and assertions into Model.