SQLite Database code refactored.