Improved cleanup code
Improve first run case (no config, history)
More logging