On the smoothness of value functions and the existence of optimal