Fixed TypeError when adding an instance to a collection.