Added explicit checks for null in the linked list collection.