bug fixes for removeFirst() and removeLast()