Fix some issues with counting correctly