huge refactoring of "reference" types