Fixes from Petr rebased

This rebases #423 - minor fixes from Petr