Added advancedReplacements method. With tests.