master copied from ownCloud