55 pages; v4 split in two - other half is now arXiv:0908.1963; v5
  final version, to appear in Adv. Math; v6 incorporates contents of a
  subsequent corrigendum concerning geometric weak equivalences; v7 corrects an
  error in Lemma 4.44 found by Andrey Lazarev