Moved counting stuff to better places