Fixed warning and compilation error when using clang.

Warning was due to the use of 'typename' outside a template scope.
Error was due to a friend declaration of a static function.