add some comments and make some replacements case-insensitive