count_objects method.
Better exception handling.