refactor getEmptySubstitution + some small other things