Resolve nested refs properly.