Fixed all segfaults and leaks !

ONE leak of 96 bytes remains, but is unknown...

Signed-off-by: Lasconik <caillouxnicolas@gmail.com>