cleaned up rtnPtr; fixed localmalloc