Add caching and some fixes