Thanks to @danilo for spotting two bugs resulting from past refactoring that went unnoticed in the field. Using flake8 I found another one.
flake8
@danilo