added some subsections and corrected some typos in the appendix