Need to pull the gcc-4.8 bug workaround to my branch

Seems that gcc-4.8 has problems with templates that use abstract types.
Whatever. Its almost dead code, the template is used in only one place,
so just expand the template by hand.