Patched with latest changes from private repo