Proper movement when inserting and deleting

Especially around the edges of lines.