Added try-excepts around url-ports and check for url before imaging.