Spurious ack handling

The queue was getting messed up if the remote receiver sends acks for
events without the resendFlag set to 2 so I have added ack handling
according to resendFlag and also a guard against
queueNewCount>queueSize.