Copy madlib before substituting. Fixes #4