a set of patches fixing wrong func calls, types, memleaks and crashes

These patches were needed to get rid of compile warnings, memleaks and crashes (mostly hapenning in STRING_TO_MIXED code).
But other array types were also affected by memleaks etc.