support for variable period lengths, bugfixes