speed up in sumfunct, treemaker

removed loops to replace -1s with 0s to faster versions