Fixed cursor position being incorrectly restored (fixes #116; ref #89).