1.7 for 1.8

Mostly a mechanical merge. Some conflicts, and an extra commit to fix compilation due to type changes.