renames functions and reformats in some areas to be more pythonic