Generic linked list implementation