genericfunctions cleanup
cherrypicking from hierarchical
removed some other unused stuff
some random changes