only send a message if we have new data

also minor refactorings