[MOD] Refactoring static variables and functions.

Fixes public/private declarations and variables leaking into other
modules.
Merge pull request #689 from LeoWoerteler/static-decls

[MOD] Refactoring static variables and functions.