more refactoring, mostly channels and magic