Fix problem with join_paths and reference handling.