some cleanup and a new function
Merge branch 'master' into gray
some more cleanup
Merge branch 'master' into gray