Apply suggested mutex fixes and improve basic squashing.

This is a quick pass at the leftovers from DM-199.