Clean up code style and add Apache 2 license to files where it was missing.