renaming definitions of generic types for clarity, avoiding use of list.tail when the list can be Nil, and improving warning messages