Do not modify last path when using replace
fix undefined variable message
fix undefined mergeInto