rewrite of refs using pg_cruft