Fixed a minor bug with the entity manager