Fix hw05 memory leaks