did some clean up.  The code should be easier to read now