Manually copied in two changes from Morgawr's pull request