Add function keys.
Fix some more end of buffer problems.