https://github.com/lad1337/XDM/blob/master/xdm/plugins/bases.py#L427