improved BTree code