Add comments and actual working functions.

Added working functions and appropriate comments describing the.