Passing most tests; simplifications and perf improvements (i.e. tree balancing) needed