Fix parent ref logic