Implement entity caching and add performance improvements
Remove obsolete code and fix remaining methods