Only try to remove the namespace from classname if there is a namespace and add backslash for non namespace classes

For non-namespace classes this substr/strlen algorithm removed the first character of the classname.
The slash is needed when generating namespace classes, which use non-namespace classes.