Created a new branch from an up-to-date codebase and added the features ...

Supersedes #2587. The old pull request was so outdated that I decided to re-do the work starting with a fresh checkout from master. Since this is technically a new branch, I'm opening a new pull request.