make coding convention conform PEP8 standard, tweak performance a bit