cleanup and null socket fix