fixed: some issues pointed out by valgrind

SPLIT ME