Refactored python files

Made the code more standard and pythonic