fix memory leaks, update scf.hf API