s2w/s2s/dt2w: Cleanup and re-implementation

* Thanks to Flar.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>