Make work for mac and fixes