Fixed bug where failing to specify a port would cause the application to use port -1