rhbz988202 Refactor and replace sleep-synchronisation with latches