some community query changes made by @kjaebker, plus some debug stuff left out for now