Updated modelgen for compatbility with latest PHP