Fix bugs with task planning