Refactoring code in order to support multiple protocol stacks. Javadocs.