Fix pipelining, add safety check.
Fixes #3