Start monitoring uses of withContext, related to issue #2112

- [ ] Do a final read-through of the code.
- [ ] Write more unit tests.

This is probably not ready to merge (though it shouldn't break anything).  Would appreciate feedback.