tried to get rid of few valgrind bugs