Misc. cleanup in file state/module

Single quotes, minor pep8 fixes ("x not in y", instead of "not x in y"),
and clarified a few comments.