More robust input handling.