Fixes and refactorings related to issue #25