Various fixes
- bad parameter name used
- variable names overlaps with build-ins (type, file, sum)
- some PEP8