Rule filtering

Completes #7. Additional feedback welcome.