Resurrected deleted non-square segment code.  Added some helper-functions for clarity.