Fix bugs in bptree