cleanup and refactor ws, this should work on Linux now