Added barriers correctly

Fixes #1406