Tp/quality improvements part 1

First bunch of code quality improvements : cleans-up, PEP8 compliancy, removed deprecated has_key.