Added Python 3 support.

Added Python 3 support, and additional code comments.