Commented

Added comments and documented functions.