fixed singleton, improved entity manager