Bug fix + cleanups in filter.