Lock was being held for far too long
OnPublished wasn't being called for QoS 2
Merge pull request #1 from Flori1989/cleanup-and-locks

Cleanup and locks