Fix cursor positioning bug

Fixes #17