more robust handling of Deferreds
- fix some pylint warnings