Reorganizing, fixing input scanning