Improve comments and formatting