free double pointers correctly

Corrects freeing of double-pointers, so every pointer is freed and stops massive memory leakage!