Improved input handling.