First work on refactoring the wamp code.