add caching & other improvements