Deal with setting maximum ports
Added clear state transitions and simple cleanup