restructured global variables and added some doc lines