Add counts and refactor.

You can now use sample_count() and friends to get a total number of given
objects available. You can pass arbitrary search parameters too.

Refactor the code so that the generator and single fetch both use the same
function to actually fetch.
Update docs.