Made sure nothing tries to use the logger before it's initialized. Added lots of logging messages, mostly debugs. Made some comments. Changed the exit/shutdown procedure.