Make rerun cache path configurable & optimise cache dump

Fixes #543