Dynamic Memory Allocation (malloc, free)

Every malloc should have a matching free on removal; watch double-free and use-after-free when reordering pointers.