lots of edits. new appendix for optimization method. more work on matrix
stuff, but still not perfectly equal...