Issue #119: further refactoring and simplification