Fixed model bugs