Reordered scripts to be more readable and added in more comments