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 "".
Assigment, not comparison!
Merge pull request #1 from atz/master

Cleanup comparisons and one bugfix