More comments, understanding has improved.

Can replace most of this with C# style objects for easier usage.