fixed some ref bugs, made some more