Fixing up the main loop a bit.  It's not ready yet, but it's compiling.