Final clean up and code refactoring after the WS. Missing comments still.