channels/rail: start refactoring