Midway through adding documentation and general code clean up.