Fix more re-definitions and enable F811/F813 in gate

Additional issues found by flake8 by enabling F811 and
F813. There was only one F813 list comprehension redefinition.
The rest of the changes were F811 redefinition of unused name
violations.

Change-Id: Iad5406c149ab21d360b7e98899a92082197c8c17
Merge "Fix more re-definitions and enable F811/F813 in gate"