Replaced a clumsy set of boolean flags that were used to make input smooth with a HashSet.