sqlite: improve cleanup