did a bit adjustment for the new merged code about null object detecting and socket resource releasing