refactored data channel event listeners, code organization