Rebased onto latest Razor changes.

- Also addressed code review comments.