s2d: Initial coding.
s2d: Fix-up small errors.
s2d: Initial logic coding.