Refactored a lot.  Still pretty crappy, but made some progress in understanding it
More treap problems