Rule filtering and some bugfixing.