more robust cachefile handling

avoids losing or corrupting cachedata when saving gets keyboard interrupted
always log to stdout