Added unhandled exception handler.
Added helper class to determine port.
Merge pull request #2 from sgade/master

Improved port determination.