Imported changes from latest master.

Sharpened Traun's master/0d3ca4de5a0674ae52a9674a41f8c1b3fad0432e.
This commit represents the completion of replication. It also includes
quite a few changes to other existing classes. These changes will
need to be ported as well.