Improved code flow and comment documentation