Linked lists refactoring and stacks resolution