Bug fix in get_refined_structure