Tidy up anchor logic