Cleanup code: reformat code, adding consistent license headers, cleanup xml documentation.