Get most of the autocount code working
A few minor bugfixes