Did a lot of work.

Also fixed up formatting.