Fixed a couple of compilation problems on VS 2005

'const reference' -> 'const_reference' and added a few missing 'typename' keywords.