refactor module internals

Since the many changes the modules have experienced it is necessary to rewrite some of them to make them more readable, shorter and error proven.

First refactor is around WebSocketUpgrade (error management is currently missing).

PS:
There are some doc changes commited I forgotten to push to the before pull request..