Merging from the r1_fix branch

The first set of merges is almost identical to those described in Merging two branches.