Applied Callum's changes by hand to avoid merge conflicts