Made some changes to logging, removed repeated code and fixed a bug that meant that debug mode was unusable.

I have noticed that plugins aren't automatically being reloaded after their contents have been modified.