Improved code quality and comments