File headers with license, automatic code reformat.
Fixed issues found by code analysis.