public synchronized String filter(String input) {
        reset();
        String inputString = input == null ? "" : input;
        debug("************************************************");
        debug("              INPUT: " + input);

        inputString = escapeComments(inputString);
        debug("     escapeComments: " + inputString);

        inputString = balanceHTML(inputString);
        debug("        balanceHTML: " + inputString);

        inputString = checkTags(inputString);
        debug("          checkTags: " + inputString);

        inputString = processRemoveBlanks(inputString);
        debug("processRemoveBlanks: " + inputString);

        //inputString = validateEntities(inputString);
        //debug("    validateEntites: " + inputString);

        debug("************************************************\n\n");
        return inputString;
    }