BZ977 Fix for endpoint/port initialisation (Based on patches from Quynh Nguyen)