Fixing errors when using nested models