Commenting and fix some formatting mistakes

Add comment, fix extra newlines, format long if statement.