Improved readability of Python code according to style guide; Better exception handling.