Refactored svg drawing code into a class.