COOPR:629 Update template APIs to support extending templates and including partials

@jwang47 Branch ready for review.
Since we made a lot of things mutable sets/maps, let's move the immutable copy to the `build()` method of the builder, so that a built object doesn't use mutable sets/maps.