Refining leading, trailing ' trimming, changed keypair to tuple