undo/redo replace lines

- you can now undo or redo replacing a line with another line.
- other bug fixes