Cleanup tree implementation a bit