fixed some ref errors
consistency check still failing
more debugging