Small refactoring of routine generator code