1.9dev b commit. Rewrote caching using objects. UNTESTED