Improved sqlite refactoring
- Added some checks for availability sqlite
- res2count and res2row cannot be combined.
- minor changes