Applied Oskar's libc++ patches from #828 to master