More code cleanup and documenting.