Cleanup and fixes.
Merge branch 'master' into withStaticInstance