Bug: replace sometimes cuts the last part