Added 401 support

initial code was causing issue, should be fixed now.
Added some proxy fixes