debug: str() cast added.  debugging prints improved.