Added Matt's changes again because I bodged up a merge. Ooops D: