Fixing compile errors due to lots of missing typename keywords and some
esoteric C++ template syntax.