EntityManager: improved code.