Fixing sqlite3 errors