Improved model factory