Added allocate_port functions. Fixes