incorporating more suggestions from https://github.com/nltk/nltk/pull/544