Working major refactor, including debugging output option.  Works in Celery mode