set_name now occurs before set_parent.

Also check for existence of name before setting reference in the parent node.
Merge pull request #50 from teem2/namefirst

set_name now occurs before set_parent.