Remove dependency on document object
Improve replacer detection