Rewrite and improve slice assignment.