Port changes from b917a94 (omniti-ms) to the template branch.