Fix uninitialised variable and more error checking

Added sanity checks to returned data and removed unused tag sorting requirement in query. Fixed uninitialised variable `want_changesets` which was being used without initialisation.