Found the problem. It was needed to update the up vector during pitching.
void rotatePitch(double rotationAngle)
{
glPushMatrix();{
loadCameraDirections();{
glRotatef(rotationAngle, dirRight.x, dirRight.y, dirRight.z);
loadCameraDirections();
} glPopMatrix();
lookAt = position.repositionBy(dirForward.reverseVector());
up = dirUp;
}
This solved the problem.