Cleaned up code
Lots of changes for the model.