Vary ws protocol based on http/https.
Removed unused code.
Workaround duplicate issue.