Changed SQLite queries to be synchronous.