lots more reference fixes
more refactoring
more and more