Finalizing use of data structure
allocation and desallocation to allow valgrind use
memory leak correction