Fix validperiod (fixes #12)

This is on top of the other PR