Moved the SQL DELETE in saveGame() closer to the INSERT. for pieces Added an index on gameID to the `history` and `pieces` tables