Added random port generation to main function.