subsumed leaf into sortstate part 2
subsumed leaf into sortstate part 3
Nice refactor
Putting more code inside helper classes