Fix: valgrind reports several memory access issues #9

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>