first patch for YARN-596, ready for trunk rebase