Cbridge: major merge of changes since 2011

I don't think I made many mistakes, but @ATenderholt could you check?