Improved socket mode handling