some linked list problems and cleanup