Fix memory leaks and change to stIntTuple for leaf sets