Add license text.

Fix some warnings and coding style.