Added comments, incorporated logger.