fix improper copying that lead to memory leaks