Fixed incorrectyly determining of new messages state.
Fixed window being incorrectly opened when new messages arrive.