trader: Fix memory leaks