Use more casts and less copies