Fleshed out the genind pgen function and correct minor errors in other files.

Certain files had confusing code fragments that have now been modified.
This change may increase stability in certain functions under certain circumstances.