further refactoring and bugfix for issue SCAL-418