Refactor Python files

Added some doc-strings, comments and renamed local variables that were using reserved keywords for no good reason.