Various patches and improvements

This is possibly/probably true. However I wasn't sure if counting images elsewhere would capture all possible images being written to the SVG. Feel free to change/correct it!