Fix leaks with path resolving