Renamed variables to avoid shadowing built-in types

This commit renames various variables to avoid shadowing built-in types, such as `dict` and `type`, which shouldn't be reused as variable names. This is subjective, of course, but it avoids confusion when reading the Python code, as these identifiers are more often used as types.