Added comments and added some documentation.