Make the CLI scripts more db agnostic (tested with SQLite)
Plus some minor tweaks