Improve error logging

Also ignore messages about unset vars
Add a simple (memory) caching mechanism that is reset on all changes
Change the caching solution

Before the cached ranges were incorrect after rebuilding the tree index