Fill gaps in period query

Completes the partial implementation from previous commit.

@robyoung
@maxfliri