a couple changes left to fix the ref stuff