Implement count. Closes #358