Addressing #60 - use window.location.port when appropriate