various problems fixed

Signed-off-by: Tom Everett <tome@criticalmass.com>
refactoring

Signed-off-by: Tom Everett <tome@criticalmass.com>
better cache stats

Signed-off-by: Tom Everett <tome@criticalmass.com>