Improved filtering of special characters