Rewrite and additions

Added a new ‘beforeRequest’ event
Completely rewritten the way requests are processed
Added new variable