Updated to allow custom headers, fix scoping of .url function