Refactored SinglyLinkedList class.