to get the master of the Mathematical School replaced by a man who knew more about the sea, he was rewarded for his service as a Governor by being made a Freeman of the City of London. He also served as Master (without ever having been a Freeman or Liveryman) of the Clothworkers' Company (1677-8). At the beginning of 1679 Pepys was elected MP for Harwich in Charles II's third parliament which formed part of the Cavalier Parliament. He was elected along with Sir Anthony Deane, a Harwich alderman and leading naval architect, to whom Pepys had been patron since 1662. By May of that year, they were under attack from their political enemies. Pepys resigned as Secretary of the Admiralty. They were imprisoned in the Tower of London on suspicion of treasonable correspondence with France, specifically leaking naval intelligence. The charges are believed to have been fabricated under the direction of Anthony Ashley-Cooper, 1st Earl of Shaftesbury. Pepys was accused, among other things, of being a secret member of the Catholic Church in England. Pepys and Deane were released in July, but proceedings against them were not dropped until June 1680. Though he had resigned from the Tangier committee in 1679, in 1683 he was sent to Tangier to assist Lord Dartmouth with the evacuation and abandonment of the English colony. After six months' service, he travelled back through Spain accompanied by the naval engineer Edmund Dummer, returning to England after a particularly rough passage on 30 March 1684. In June 1684, once more in favour, he was appointed King's Secretary for the affairs of the Admiralty, a post that he retained after the death of Charles II (February 1685) and the accession of James II. The phantom Pepys Island, alleged to be near South Georgia, was named after him in 1684, having been first "discovered" during his tenure at the Admiralty. From 1685 to 1688, he was active not only as Secretary of the Admiralty, but also as MP for Harwich. He had been elected MP for Sandwich, but this election was contested and he immediately withdrew to Harwich. When James fled the country at the end of 1688, Pepys's career also came to an end. In January 1689, he was defeated in the parliamentary election at Harwich; in February, one week after the accession of William III and Mary II, he resigned his secretaryship. Royal Society He