[#3] Fixed memory leaks