Add discard-filter support

Not yet ready for merge.