Backport

This pull request does three things:

1. It backports the relevant parts of the wait_time_compression branch to the mmri-rt branch.
2. It brings the mmri-rt branch up to date with the current version of the master branch.
3. It includes the changes of pull request #1337, so that the mmri-rt branch also remains up to date.