rework counting
quite a few fixes