Added some description of why I wrote this.
Cleanup: removed dead code, reorganized code.