Merge my changes with Edmund.
Pending merger into master branch.