Re-work index into a simple match on endsWith(), and fix some review nits.