Fix remaining bugs backporting port hardening