Fix some bugs in delete_old_branches