SQLite implementations and memory issue fixes

SQLite implementations and memory issue fixes