Finished refactor of entity functionality.