Polish and refactor some of the internal SSL code to make it easier to add additional functionality in the future.