Added filtering of observations when calculating mean and stddev. Fixed mixup between insertion and deletion.