Improved cache system for per-request cleanup.
Added shim for Python 2.6.