Fix mac os bugs