Fix for wakeup hang

The main purpose of these changes is to fix an issue where a reading thread could hang at wakeup (seen this happen, this fix was tested to correct the issue)