Testing regule

Merge the final version for the regule algorithm.