Moved some JS vars to the scope they belong to