Caching system and little bug fixes