Fix undefined property bug when a model containing a collection is replaced