Allow building MainNoGUI and MainGUI simultaneously

Do some cleanups to allow this to happen. I'm going to be considerably revamping the interface here, and in order to do that, I need to make sure it's tested properly.
Can't this be a foreach loop?