MNT: Made some changes to the code based on Caswell's comments