fixed getting the numbers of messages;
some fixes;