Refactor logging system
Make API logging / usage more sane.