Use factory for node creation.
Merge pull request #24 from pbidenko/Factory

Use factory for node creation.