Add license header and minor code cleanups.