Lots of code clean-up.
The connection module has now been separated out in to smaller functions, as much as possible.
PEP8.
PYLINT.