Simplified and improved performance of filters.

Signed-off-by: Grant Skinner <info@gskinner.com>