rewrote sumfunct2 from scratch

significant speed up - vectorised sumfunct2, 7.45 for sumfunct, 0.59 for
sumfunct2. Needs a little clean up to export correct formats etc, but
it's working.
Also fixed sumfunct from previous breaking.