AARGH. There are two lumps of (almost-)identical code to handle