Cleaned up and commented a lot of code.
Merge conflicts.