js refactor part 1, back to normal behavior. lots of variables changed.