Cleanup: code, file header/copyright/license, and error messages