Fixed exception so library works with Python 3.3 and random pep8 cleanup.