Refactor the prepare_input module.