Remove redundant backslashes

They are not necessary between parenthesis
Whitespace cleanup

As per PEP8, global functions need two newlines, class methods need 1, and all indentation should use spaces, not tabs
Add missing whitespace between operators
Remove unnecessary imports

Also list out top-level imports separately
Clean up logic behind indexing
Use proper indentation