[cs] clean up casts in an lvalue. Closes #3118