[filter] some improvements to the core filtering code