Added SVG support and improved code