Code cleanup and functionality

Got the code working again, cleaned up some junk, and renamed a few
variables.  Still have to clean up a little more and add comments.