Fix bug in and optimise VPTreeMapped implementation, and add WritePairs command.