refactoring finished; next step: barrier handling