fix shadowed variable bugs and undefined cpp macro bugs.
16 files changed