Rewritten the rule composer for being more efficient.