Major refactoring/formatting. Fixed issue with WebDriver cookies.

This pull request contains a major formatting/refactoring of the code. There're still things todo, especially in term of performance and errors handling. Nonetheless, the code should be more readable and easy to follow. Although I haven't performed extensive testing, the plugin should work as before.

In addition, I modified the code in charge of setting WebDriver's cookies as I found a bug that was preventing to set cookies under specific circumstances. Hopefully, I didn't break anything.  Have a look, Cheers!