Remove dead code and optimize boolean filter