Memory leaks, bugs

Fixed some memory leaks, renamed structs and fixed some minor bugs

Signed-off-by: Elias Vansteenkiste <Elias.Vansteenkiste@ugent.be>