Fix prefix and repo_path memory management