[2.0] Fix various socket engine bugs.