Fix some missing stream locking

This also adds a verification assert.