Added appendix A, changed code snippets.