Improve support for replace()
Nice error logging for CLI