Fist working version of code.  Still a lot to add.