A bunch of changes I apparently didn't add into afd809d1e91c7b6b581c4f45104655d243cb9bc4