worked on better json support, ref_isvalid etc