added license, fixed mem leak