Fix up texture coordinate generation to take into account margin, spacing and padding. Make sure the stage cleans up properly