All three PRs in one!

There was a merge conflict with the last of my previous three PRs. This combines them all into a clean PR that should apply to your master branch.