greatly improved code readability and formatting of everything but the main