Changed order of chapter 3 and 4 and fixed reference issues.