A few stylistic changes to make the code more pythonic.