CRM-14241, added entity manager and cli mode fixes