Continued to build out optimize_over_X function; switched to converting X to vector format before running optim.