Fix static initialization bug in entity manager