Add interval count parameter

Replacement pull request for #91 which seems to be abandoned.