Bug fixes and refactoring caches