Working on it now. There's lots of optimisations I can make here, actually.