Better error handling for command line
Fix port assignment in windows