Change how filtering is implemented and make length fields optional