Refactoring software to a more pythonic version