Fix invalid free after template postprocessing stuff