Tweak Javadoc. Add since tag, reformat code. Simplify tests. Move documentation bits into the right place. See #3726. Original pull request: #3765.