Build contribs in the right order and link them in the right order.

This particular bit of code wizardry is making me loopy.