fixed some memory allocations to prevent valgrind warnings