Make icon replacement more robust