REFACTOR: moved interval stuff into separate package