Corrected method signatures and fixed file replace bugs. Replace works properly now.
Fixes #2420