Simplify prefix handling code