Fixed many license problems, spotted by licensecheck program

Partially fixing issue #769