Move unchecked casts to a single location