adapting last changes from port.