replace some transmutes with casts