Migrate some shareable code to model module