pep8 and python 3 fixes

Hey I've removed a bunch of ';'s and formatted the code nicely. I've made a couple of dict.has_key('x') changes to 'x' in dict.