fixed non-trivial bugs with rule ordering and unification