Improved creation of entity object