Refactoring
cleanup pass.
fix most comments.
fix multiple issues
remove dead code
fix more nits
fix more nits
fix more nits
fix more nits
refactoring done.