Fixed segfualting deconstructor by using rm() to delete the nodes