fix unwanted free calls an some segfaults