cache optimizations, bugfixes