corrected error handling and mac-specific build issues