SHA processing bug fix and cache timeout feature

Rebased pull request on master per #404.