Clone rules before modifying.

Fixes #47.