Adds fixes from @wchen-r7.