Fixed Errors and added comments

Fixed Errors and added comments