Fixed mutex sequencing plus some general tidy-ups