Small tweaks and fixed replace_line