Issue #77: a bit of refactoring