Fixed a few small bugs and started refactoring the logger a bit.