Base64 encode svg as Firefox doesn't like it in plain text, Whitespace tweaks
Typechecking to avoide NaNs (I hope)