Fixed memory leak and added license
