Formatting fixes.

Use space after ',' and ';'.
Use '>>' without spaces for nested templates.
No space before () in function declaration.
Use formatting "TYPE const&".
Remove superfluous and inconsistent whitespace.
Add comments for closing namespaces.