More organization. Less crashing hopefully.

I think everything is fixed now. There was an undefined variable that really didn't make sense where it was (the while (p < 6) loop).