Fixed ArrayIndexOutOfBoundsException: 0 when there are no replacements.