Fix various compilation errors

After pulling out a bunch of implementation code from the header files, some
compilation errors resulted.  To fix them, some explicit instantions were added
and the implementation of operator<< was friended and put inline in the header.