Nonconvex Optimal Control and Variational Problems