Fix a bug and improve tree expansion choice