It was very much based on the Milverton story and
Love the casting as well
at the end to keep to the original story Sherlock had to kill him as in the original he destroys the archive of material Milverton was using for blackmail. As in this version it is entirely in his mind then the only way to destroy it was by killing him
Love the casting as well
with Martins real wife playing Mary and Benedicts actual parents playing his parents