Some results on well-posedness in scalar optimization problems and in variational inequalities