Rearrange clusters into a chain

(I've not tested in yet)
A few bugs fixed.