Code reviewed, and compiles.  Not yet tested.