Made debug global, minor fixes

Mostly just neatened code more, and prepared Main.

@CameronDarragh We should discuss what we actually have to do, and how
we're going to do it. Skype sometime?