A whole bunch of updates including source code listing in the appendix