Fix memory/routine leak