Added some additional input validation/error handling.

Signed-off-by: Nigel <Nigel@192.168.1.103>