Fix debug/log output path so it is much less messy (issue #597)