Update model.js

Several improvements for model