Rebased from toString branch