Fixes some synchronisation bugs.