Thread safe implementation of block. Closes #370.