updated debug output, fixed memory access in sgs_ToStringBuf