Use node.set for reading and writing - fixes #59

Use `node.set` and refactor the code to look less magical.