Here are the first two fixes:
https://github.com/discourse/discourse/commit/5bf3a00328c63755ddc8482a6c88ca9088f97881
https://github.com/discourse/discourse/commit/4cd620e36eaefa29035a859f4f74726a2d0e7a05