Rearrange the policy handling code