Added comments and made minor changes