Add docstrings and doctests to pbot.py + Python cleanups.