Add further precondition checks

This makes pop() and peek() consistent with first().