Further in progress refactoring for issue #574