Started refactoring ws-cs.js

:)