Added an option to remove the first or the last item on the list.