sharing api cleanup

Some first steps of the sharing api cleanup. The last weeks it become quite hard to backport bugfixes from master. Therefore I would like to merge this status as an intermediate step.

cc  @PVince81 @DeepDiver1975 @karlitschek