Adding averaged samples \nAdding possibility to specify custom rules