Code cleanup
Return -1 when failed to publish message
Merge pull request #1158 from hurtonm/master

Code cleanup