Move entity code into separate entity manager class