Fixed in-place HCDFT allocation logic.
Added missing close statements for dft plans.