cleaning up and middleware forcessl addition