improved comments and formatting