updated rebuild_page_tree (still incomplete/untested)