Cleanup undef comparisons, use defined()

This is required to run under warnings pragma.

My only concern is points where you might have been relying
on an empty string == undef comparision, particularly where the
telnet client code might return "".