Added input sanitization.
Refactored client code.