Bug fixes + Modified python code for PEP8 compliance