Move model-related methods to lib/model