Moved around a lot of javascript. Fixed up a few other things.