moved channel-related code into its own source file