Refactor the EntityManagerWrapper.