Fixed and added comments

Fixed most of the errors that were occurring. And added comments.