Added caching, few other changes