AccumulatorCache: code cleanup
Purely code cleanup to make it more readable/maintainable:
- introduce
NotHashable
exception to handle un-hashable function arguments rather than checking it beforehand - reduce excessive nesting by moving some if-checks
- cleanup doc-strings