bugfixes w/ refs