bug fixes, handles non-standard URLs

Fixed a few bugs and modified the script to work with non-standard
ArcGIS Server URLs.