Make use of fact that isinstance also accepts nested tuples
Some flake8 cleanup