Fixing defer note bug and closing unclosed divs

When defering the note dialog was passing previous defer-notes. By
clearing out the dialog div before closing it this problem is fixed.

Also fixing a bunch of <div> tags which were not being closed.