Updated some methods to use EntityManager.