Enable Py 3 compat, refactor function

Make code compatible with Python 3. Refactor the `subscribe` function. For exact details, please see the commit messages and commit diffs.
Better to go with `from __future__ import print_function` if it is python 2. We don't need to support Python 2.6