Fixed bug in the profile for Model; Refactored some code