Complete rewrite of logging system.