Some refactoring of log and cfg stuff.