Fixed a dumb bit of code and make some debug information less intrusive so the logic is easier to read.