Pullrequest

Fixes and new feature (output_period).
It is ABI/API compatible. They can be cherry-picked onto the master branch.