Various changes to make indentation match PEP8 guidelines
Refactoring to reduce line length of too long lines