Reordered JS scripts and added in comments