Avoid redefining switch dict in each loop iteration
Pep8 fixes