integrate R commits by @MatthiasHinz