updated darwin detection and some fix