added comments

Added descriptions to the whole file and comments to the functions
inside.