SqliteTableModel: Inserting and deleting rows, clean up, bug fixes

Add some basic code to support inserting and deleting rows again.

Fix a few bugs here and there.

Do some general code clean up.