Fix misuse of retreiving the port and direcotry index.