take some fixes from xembed