Cleaned up the model code