Refactored SQLite code

Refactored some code in Character Data Source