Added license info to file headers, fixed potential memory leak