Cleaned up search implementation of filters.

Fixes #2151