Remove unnecessary (but unexecutable) unlocks, cleanup code (bug #6220)