Formatting

Mostly whitespace editing. Only the last commits changes the code in order to remove warnings/errors reported by passive python checker pyflakes.