Cleaned up SQLite code