finished revision of chapter 3 and 5, various other fixes and enhancements