Added error checking for collections and models.