minor code fixes
more fixes related to caching