Adding removal of cache dirs

This includes better handling of cache states.