Added much of 1D main loop