* Clarifies comments and documentation. * Adds type-hints. * Fixes Python 3 compatibility (and runs pyupgrade). * Updates for changes in Synapse internals.