[WIP] Added new self-consistent code and notes.

Here is my new code and some PDF notes showing the math.