Add license, minor changes to code