Make the functions local to this script.
Fix insertion of newlines.

Insertion of a new line while the cursor was in the initial whitespace
characters of the current line was buggy.