channels/rail: refactor