The extension side of the implementation is ugly, this function is not // well-thought and the whole thing is needlessly hard to test. At the very // least it should be made asynchronous, at best it should be removed // altogether. // It is being kept for the time being for backwards compatibility.