Fixed some bugs in the planner and in the rules.