fixing some ifdefs and some problems with previous merge