Fix ref errors