Beat the legacy code into better shape.  Generally working