corrected typecast
moved casting fxn.  Fixed segfault for copying of empty record