Added some minor fixes to replacement