Almost done.  Needs testing