Add ref and tidy