added caching and misc fixes