Improved input sanitization