Replace mode bug-fixes and early scan implementation