Simplify anchor generation code.