SQLite plugin and some architecture refactor