Updated comments and spacing and some logic.