function: mark all unread messages. Fix bugs.