Add model factory, minor changes