Improved exception handling and also fixed some warnings.

Signed-off-by: retep998 <retep998@verizon.net>