add ifdefs etc fix some build errors