Started rewriting to match changes in input method.