This was already partly done by @cexikitin in #65, I'm just finishing it off in their absence! Closes #65