added rules filtering; minor bug fixes