Fixed issues where img elements were put in the wrong place. Image generation now strips commented lines before running latex