fixed some illegal memory access by adding init funcitons properly

FIXME: valgrind reports memleaks