MERGE: Bring in most of Dan's mr codebase, renaming as needed.