fixes #18, cleaning up cache file at appropriate time