Added unhandled exception handler.
Added helper class to determine port.