Refactor copy&paste mechanism
Fix bug in cursor modification