Issue #31: Integrated cache manager with CWS.

Note that the integration code is awfully ugly, but I had to follow
mequrel's style (which fortunatelly will be changed soon).