Finish code for appendix. Needs a bit of a cleanup