Bunch of small refinements in kernel