Tries to make the cache directory configurable.
Merge pull request #937 from andersonamuller/master

Fixes #705