Refactor svg generation

This is just to help me understand the code, really!
Merge pull request #44 from meshy/refactor-svg

Refactor svg generation