Make the barrier code a library
Small bugs.