Fix some bugs in bst.