Extract purity counter into separate module