Removed duplicate code.
Removed redundant entity factory.