fix bugs for mac's g++ 4.2 compiler.