Cleanup/improve global variable declarations.

This change cleans up the entire global variable mechaninism including
the related macros. Also reduces warnings from the "sparse" utility
in the Linux environment. Lv Zheng.