PEP8'ed, linted, and slightly modernized for 1.5.