Improved stats posting method

Checks for an empty buffer and clears the buffer on success to allow
multiple calls.