adding some debug messages
fix incorrect port allocations