reorder global variables; rename some things