A fairly final version. Many changes.