Try to make the plugin more flexible

This will hopefully make it possible to use all kinds of configurations from web pages to webdav and proxying.

At the moment the code is a tad.. unorganized. Please review and note where improvements can be made.