Fix bug related to freeing models when changing an object's type (would occur when changing an object's type, closing the galaxy, and opening some galaxy)