Added a namespace and prefixed global variables with "G_" in order to prevent variable shadowing problems.