[#20] Fixed memory leaks