Made robust for page refresh.