Check state before close() and logout()
Indent correctly
Open file using 'with', move debug message
Merge branch 'cbenz-master'
Remove ignored errors in pep8