Reorganized some code in EntityLoader