Improved code formatting and comments