Various small changes

* A little bit of cleanup
* Support onfetch etc
* Allow scope to be optional