Fix a few bugs in the console, and clean it up a tiny bit. Also add comments to clarify things a bit more.