This is amazing! Many thanks.
A couple of questions however:
1) How large deposit outputs (0 and 3) must really be? I think 3x is an overkill, even 1x is enough?
2) If the channel is funded asymmetrically, for instance if Alice unilaterally funds it (initial state: Alice: x, Bob: 0), how does it affect everything? Outputs 0 and 2 aren't needed at all?