Change the selection before committing deletions of lines

For whatever reason this was sometimes being done after the commit,
which resulted in a lot of code only working by coincidence when the
grid commit handler happened to be the first one to be called.
More unique_ptr
Limit shift times history to the last 50 shifts