Add some documentation to WSE and refactor a bit