Fixed counter issue caused by earlier hack to get code working. No more trailing entries in database