removed some bugs, but still have negative results from valgrind