main loop stuff tweaked.