Incorporate latest small edits and fixes.

Did some reformatting on the code. Also some resolved conflicts during past merges need synchronization.