Fixing up the main loop.  Not ready yet. but compiling.