some fixes in the original c++ implementation
bst tree mostly completed