Various fixes to prevent redefined symbols

Lots of extern template declarations, function specializations, and so forth.  No major refactoring.