Handle tree_state on reloads and fix tree_state on tab closing

review850003