Added calls to delete_list() to correctly deallocate linked lists.