Refactored favicon middleware