reference caches
finished rework on type check (to be tested)