fix bugs to comple with gcc