Which preposition to use with thereof

From Occurrences 2%

Also How He Freed a Misfortunate Castle and Town From the Giants Who Held Them, and How He Released the Lord Thereof From a Dungeon Chapter

for Occurrences 1%

Especially he is an enemy to all ladies of that country, for he hath taken many of them prisoners to his castle and hath held them in the dungeon thereof for ransom; and sometimes he hath held them for a long while.

Which preposition to use with  thereof