First pass generalize build

Profiling with Mac Instruments indicated that unnecessary memory copying was being done.  This minimizes the copies by using const references in more places.