Updated keygen code, validity checking, and

compressed keygen creation and added some more inline docs