Added counter and made a few other changes