Adding averaged samples \Adding possibility to specify custom rules