First() and Last() functions return unexpected results.