Fixed few g++ bugs