Added ability to use a separate entity manager