Refactored proxy initialiazition to make it simpler to switch between http and ssl