Fix typo in authmanager
Fix mistake in torrentmanager
Fix #2303 : Torrent state not updated until after emitting TorrentFinishedEvent
Cleanup torrentmanger code

 * Remove legacy/old state file code
 * Passes flake8 cleanly
 * Most pylint messages dealt with
 * Code now uses >=Python 2.6 'with' and 'as' statements
Add flake8 to setup.cfg and add missed change to #2303 fix