fixes for some segfaults and a memory leak caused by a misimplemented successor
function