Fix filtering bugs