Cleanup role assignment and lock logic