Minor refactor
Will now try to auto detect proxy and use it if possible
make code clearer