some refactrings suggested by kibit
misplaced docstring
duplicated defn
misplaced docstring
eastwood suggestions
some refactorings from eastwood