Fixed entity manager bug