[#16] Fixing some memory leaks