Minor improvements to input filtering